<template>
  <div class="box2">
    <div class="title">
      <p>年龄比例</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as echarts from "echarts";
//组件挂载完毕初始化图形图标
let charts = ref();
onMounted(() => {
  let mychart = echarts.init(charts.value);
  //设置配置项
  let option = {
    tooltip: {
      trigger: "item",
    },
    legend: {
      top: 40,
      right:60,
      orient:'vertical',
      textStyle:{
        color:'white',
        fontSize:14
      }

    },
    series: [
      {
        name: "Access From",
        type: "pie",
        radius: ["40%", "70%"],
        avoidLabelOverlap: false,
        right:110,
        itemStyle: {
          borderRadius: 10,
          borderColor: "#fff",
          borderWidth: 2,
        },
        label: {
          show: true,
          position: "inside",
          color:'white'
        },
        labelLine: {
          show: false,
        },
        data: [
          { value: 1048, name: "0-10岁" },
          { value: 735, name: "10-20岁" },
          { value: 580, name: "20-30岁" },
          { value: 484, name: "30-40岁" },
          { value: 300, name: "40-50岁" },
          { value: 300, name: "50-60岁" },
          { value: 300, name: "60-70岁" },
        ],
      },
    ],
    //调整图形图表的位置
    grid:{
      left:0,
      top:0,
      right:0,
      bottom:0
    },
  };
  mychart.setOption(option)
});
</script>

<style scoped lang="scss">
.box2 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;
  .title {
    margin-left: 20px;
    p{
      color: white;
      font-size: 20px;
    }
  }
  .charts {
    height: 260px;
  }
}
</style>
